(texmacs-module (contrib physics physics-func))

(tm-define (physics-dv args-t)
  (:secure #t)
  (let* ((args (map tree->stree (tree-children args-t)))
         (N (length args)))
    (cond ((== N 1)
           (stree->tree `(frac "d" (concat "d" ,(first args)))))
          ((== N 2)
           (stree->tree `(frac (concat "d" ,(first args)) (concat "d" ,(second args)))))
          ((== N 3)
           (stree->tree `(frac (concat "d" (rsup ,(first args)) ,(second args))
                               (concat "d" ,(third args) (rsup ,(first args))))))
          (else "Incorrect number of args"))))
